#define FHE_PUBKEY_BYTES		1024*256
#define PROTECT_KEY_CRYPTO_LENGTH		116
#define FHE_PRIKEY_BYTES		32
#define FHE_CYPHER_BYTES		128
#define ECCref_MAX_BITS			256
#define ECCref_MAX_LEN			((ECCref_MAX_BITS+7) / 8)
#define FHE_SM2_INPUT_MAX		512
#define FHE_SM3_INPUT_MAX		1024

#define SGD_SM3					0x00000001
#define SGD_SM2_1				0x00020100		//SCE Signature Alg
#define SGD_SM3_ID				0x00000040

typedef struct ECCrefPublicKey_st
{
	unsigned int  bits;
	unsigned char x[ECCref_MAX_LEN];
	unsigned char y[ECCref_MAX_LEN];
} ECCrefPublicKey;

typedef struct ECCrefPrivateKey_st
{
	unsigned int  bits;
	unsigned char D[ECCref_MAX_LEN];
} ECCrefPrivateKey;

typedef struct ECCCipher_st
{
	unsigned char x[ECCref_MAX_LEN];/*32字节*/
	unsigned char y[ECCref_MAX_LEN];/*32字节*/
	unsigned char M[32];
	unsigned int L;/*密文数据长度*/
	unsigned char C[128];/*密文数据最大长度128字节*/
}ECCCipher;

typedef struct testECCCipher_st
{
	unsigned char x[ECCref_MAX_LEN];/*32字节*/
	unsigned char y[ECCref_MAX_LEN];/*32字节*/
	unsigned char M[32];
	unsigned char C[128];/*密文数据最大长度128字节*/
}TestECCCipher;

typedef struct ECCSignature_st
{
	unsigned char r[ECCref_MAX_LEN];
	unsigned char s[ECCref_MAX_LEN];
}ECCSignature;

int FHEKmg_Create_Kekey(unsigned int uiKeyIndex);

int FHEKmg_Backup_KeKey(unsigned int uiKeyIndex, char* kekey_str);

int FHEKmg_Restore_KeKey(unsigned int uiKeyIndex, char* kekey_str);

int FHEKmg_Create_Sm1key(unsigned int uiIndex);

int FHEKmg_Backup_Sm1key(unsigned int uiKeyIndex, char* sm1key_str);

int FHEKmg_Restore_Sm1key(unsigned int uiKeyIndex, char* sm1key_str);

int FHEKmg_Restore_Sm1key_PLAIN(unsigned int uiKeyIndex, char* pucBpKey);

int FHEKmg_Create_FheAuth(unsigned int uiIndex);

int FHEKmg_Backup_FheAuth(unsigned int uiIndex, char* sm1key_auth_str);

int FHEKmg_Restore_FheAuth(unsigned int uiIndex, char* sm1key_auth_str);

int FHEKMG_GenerateExportFheKeypair(unsigned int uiIndex, char* fhepubkey_str);

int FHEKmg_ImportLoadFhePubKey(char* fhepubkey_str);

int FHEKmg_SaveFhePriKey(unsigned int uiKeyIndex);

int FHEKmg_LoadFhePriKey(unsigned int uiKeyIndex);

int FHEKmg_BackupFHEPriKey(unsigned int uiKeyIndex, char* fheprikey_str);

int FHEKmg_RestoreFHEPriKey(unsigned int uiKeyIndex, char* fheprikey_str);

int FHEKmg_Create_And_Backup_FheKeyPair(unsigned int uiIndex, char* pucPublicKey, char* pucPrivateKey);

int FHEKmg_Restore_FheKeyPair(unsigned int uiIndex, char* pucPublicKey, char* pucPrivateKey);

// add 20241023
int FHEKmg_Backup_FhePriKey(unsigned int uiIndex, char* pucPrivateKey);
// add 20241023
int FHEKmg_Restore_FhePriKey(unsigned int uiIndex, char* pucPrivateKey);

int FHEKmg_Create_UsrKeyPair(unsigned int uiKeyIndex, unsigned char* pucUkAccessCode, unsigned int uiUkAccessCodeLength);

int FHEKmg_Backup_UsrKeyPair(unsigned int uiKeyIndex, char* usrkeypair_str);

int FHEKmg_Restore_UsrKeyPair(unsigned int uiKeyIndex, char* usrkeypair_str);

int FHE_SM2Key(char* pucPublicKey, char* pucPrivateKey);

int FHESdf_Create_Sm2key();

int FHESdf_Backup_Sm2key(char* pucPublicKey, char* pucPrivateKey);

int FHESdf_Restore_Sm2key(char* pucPublicKey, char* pucPrivateKey);

int FHESdf_Sm2_Enc(char* pucData, unsigned int uiDataLength, char* pucEnc);

int FHESdf_Sm2_Dec(char* pucEnc, unsigned int uiDataLength, char* pucData);

int FHESdf_Sm2_Sign(char* pucID, unsigned int IdLength, char* pucData, unsigned int  uiDataLength, char* pucSignature);

int FHESdf_Sm2_Verify(char* pucID, unsigned int IdLength, char* pucData, unsigned int uiDataLength, char* pucSignature);
